<?php
//项目订单资料库（保存项目订单图纸）

namespace app\admin\controller;


use app\facade\Upload as UploadF;
use app\admin\model\ProjectsDrawingLib as ProjectsDrawingLibM;

class ProjectsDrawingLib extends Base
{
    public function filter(&$map, &$field)
    {

        $field = 'id,image,create_time,status';
        $map = [['status', 'in', '1,2']];
    }

    public function beforeDel($ids, $is_del)
    {
        //记录被删除的图片地址，删除完成后删除本地图片文件
        if(!empty($ids))
        {
            $ids = implode(',', $ids);
            $images = ProjectsDrawingLibM::where('id', 'in', $ids)->column('image');
            $_GET['images'] = $images;
            app('request')->withGet($_GET);
        }
    }

    public function finishDel($ids, $is_del)

    {
        //删除图片后删除本地图片
        if($is_del == 1)
        {
            $get = request()->get();
            if(!empty($get['images']))
            {
                foreach($get['images'] as $k=>$v)
                {
                    UploadF::delLocalFile('.'.$v);
                }
            }

        }
    }
}